/*!  
 ***************************************************************************
 *  \file uniform_meshes.cpp
 *  Examples of use of \c StructuredMesh<> class.
 ***************************************************************************
 *  \author  Luis M. de la Cruz Salas [ Sat Jan 19 18:16:37 GMT 2010 ]
 ***************************************************************************
 *  This program presents examples for using the StructuredMesh<> class,
 *  which is intended to handle structured meshes in Cartesian coordinates.
 *  In these examples the class is specialized with the Uniform<> adaptor 
 *  to create uniform meshes.
 *  \par Compiling and running
 *  Modify the variables BASE and BLITZ in the file \c tuna-cfd-rules.in 
 *  according to your installation and then type the next commands:
 *  \verbatim
    % make  
    % ./uniform_meshes  \endverbatim
 *  The file \c input contains: 1 2 3 4 5 6 which are the lenghts in the
 *  axes \a x, \a y, and \a z respectively, and the number of nodes
 *  in the same order.
 ***************************************************************************
 */
#include <iostream>
#include "Meshes/StructuredMesh.hpp"
#include "Meshes/Uniform.hpp"

using namespace Tuna;

int main() {

    float length_x, length_y, length_z;
    int num_nodes_x, num_nodes_y, num_nodes_z;

// Reading data from the input file
    std::ifstream input_cin ("input");    
    input_cin >> length_x;
    input_cin >> length_y;
    input_cin >> length_z;
    input_cin >> num_nodes_x;
    input_cin >> num_nodes_y;
    input_cin >> num_nodes_z;
    input_cin.close();

    std::cout << "\n\n >----> Mesh inicialization \n";
    StructuredMesh<Uniform<float, 1> > mesh_1D(length_x, num_nodes_x);
    mesh_1D.print();
    StructuredMesh<Uniform<float, 2> > mesh_2D(length_x, num_nodes_x,
					       length_y, num_nodes_y);
    mesh_2D.print();
    StructuredMesh<Uniform<float, 3> > mesh_3D(length_x, num_nodes_x,
					       length_y, num_nodes_y,
					       length_z, num_nodes_z);
    mesh_3D.print();

    std::cout << "\n\n >----> Resizing the meshes \n";
    mesh_2D.resize(2, 5, 4, 9);
    mesh_2D.print();

    std::cout << "\n\n >----> Using some functions \n"
	      << "\n Dimension = " << mesh_3D.getDimension()
	      << "\n Length in X = " << mesh_2D.getLength(X)
	      << "\n Size of delta in Z = " << mesh_3D.getDelta(Z)
	      << "\n Num of nodes in Y = " << mesh_3D.getExtentNodes(Y)
	      << "\n Num of volumes in X = " << mesh_3D.getExtentVolumes(X);

    std::cout << "\n\n >----> More functions \n"
	      << mesh_3D.getExtentVolumes() << "\n"
	      << mesh_2D.getDeltas();

    std::cout << "\n\n >----> Copying meshes \n";
    StructuredMesh<Uniform<float, 2> > copy_mesh = mesh_2D;
    copy_mesh.print();

    copy_mesh.resize(2, 10, 20, 100);    
    mesh_2D = copy_mesh;
    mesh_2D.print();
    
// Are you sure ?
    mesh_1D = mesh_1D;

    return 0;
}
